package adminejb;

import java.util.HashMap;
import java.util.Map;

import javax.ejb.LocalBean;
import javax.ejb.Stateful;
import javax.validation.ValidationException;

import validator.*;

/**
 * Session Bean implementation class StatefulBean
 */
@Stateful
@LocalBean
public class StatefulBean implements StatefulBeanLocal{

	Map<String, String> map;
	
    public StatefulBean() {
    	map = new HashMap<String, String>();
    	//map.put("flightnumber", "");
    	/*
    	map.put("price_ec", "");
    	map.put("price_bc", "");
    	map.put("price_fc", "");
    	map.put("av_ec", "");
    	map.put("av_bc", "");
    	map.put("av_fc", "");
    	map.put("deptime", "");
    	map.put("arrtime", "");
    	*/
    }
    
    public Map<String, String> getMap() {
    	return map;
    }
    
    public void clearMap() {
    	this.map.clear();
    }
    
    
    public void validation(String value)  {
    	try{ 
    		ValidationService.flightNoValidation(value);
    	} catch(validator.ValidationException fe){
    		map.put("flightnumber", fe.getMessage());
        	//System.out.println("Mistake is found: " + fe.getMessage());
        }   
    }
        
    public void validatePriceEc(String value) {
    	try{ 
    		ValidationService.flightPriceValidation(value);
    	} catch(validator.ValidationException fe){
    		map.put("price_ec", fe.getMessage());
        }   
    }
    
    public void validatePriceBc(String value) {
    	try{ 
    		ValidationService.flightPriceValidation(value);
    	} catch(validator.ValidationException fe){
    		map.put("price_bc", fe.getMessage());
        }   
    }
    
    public void validatePriceFc(String value) {
    	try{ 
    		ValidationService.flightPriceValidation(value);
    	} catch(validator.ValidationException fe){
    		map.put("price_fc", fe.getMessage());
        }   
    }
    
    public void validateAvEc(String value) {
    	try{ 
    		ValidationService.flightAvValidation(value);
    	} catch(validator.ValidationException fe){
    		map.put("av_ec", fe.getMessage());
        }   
    }
    
    public void validateAvBc(String value) {
    	try{ 
    		ValidationService.flightAvValidation(value);
    	} catch(validator.ValidationException fe){
    		map.put("av_bc", fe.getMessage());
        }   
    }
    
    public void validateAvFc(String value) {
    	try{ 
    		ValidationService.flightAvValidation(value);
    	} catch(validator.ValidationException fe){
    		map.put("av_fc", fe.getMessage());
        }   
    }
    
    
   

}
